package com.corticon.client.util;

import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.context.SecurityContextHolder;

/**
 * @author Yanglifan
 */
public class SecurityUtils {

	public static UserDetails getCurrentUser() {
		try {
			Object obj = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
			if (obj instanceof UserDetails) {
				UserDetails user = (UserDetails) obj;
				return user;
			}
		} catch (Exception e) {
			return null;
		}
		return null;
	}
}